package br.com.future.study.pool;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class MetricsSingleton {

	List<WorkerInfo> metricsList = Collections.synchronizedList(new ArrayList<WorkerInfo>());

	// Private constructor prevents instantiation from other classes
	private MetricsSingleton() {
	}

	/**
	 * SingletonHolder is loaded on the first execution of Singleton.getInstance() or the first access to
	 * SingletonHolder.INSTANCE, not before.
	 */
	private static class SingletonHolder {
		public static final MetricsSingleton INSTANCE = new MetricsSingleton();
	}

	public static MetricsSingleton getInstance() {
		return SingletonHolder.INSTANCE;
	}

	public void addMetrics(WorkerInfo time) {
		metricsList.add(time);
	}

	public List<WorkerInfo> getMetrics() {
		return metricsList;
	}
}
